var commanderSource = {

    /** @param {Room} nowRoom **/
    run: function (nowRoom) {
        var sourceList = nowRoom.find(FIND_SOURCES).sort();
        var index = 0
        var last = 0;
        for (; index < sourceList.length; index++) {
            if (sourceList[index].energy > 0 && sourceList[last] == sourceList[index]) {
                allowHarve = sourceList[last]; // allowHarve is global
                break;
            }
            if (sourceList[last].energy <= 0){
                continue;
            }
            else {
                last = index;
                allowHarve = sourceList[index];
                continue;
            }
        }
    }
};

module.exports = commanderSource;